/******************************************************/
/* Goblin's Cube - Rubik's cube game for Wii Homebrew */
/* Copyright (C) 2009 Ricardo Bueno Cordeiro          */
/* Licensed under de GNU General Public License v2.0  */
/*   See license_gplv2.txt for detalis                */
/******************************************************/

#ifndef __CONTROL_HIGHSCORE_H_
#define __CONTROL_HIGHSCORE_H_

#define NUM_HIGHSCORES 10

#include <gccore.h>

#include "control_base.h"

struct score_t {
	char name[3];
	f32 time;
};

class ControlHighscore : public ControlBase {
private:
	int naming_result;
	int naming_current_letter;

	struct score_t local_highscore[NUM_HIGHSCORES + 1];
	int num_local;
	
	struct score_t online_highscore[NUM_HIGHSCORES + 1];
	int num_online;

	void get_filename(char *full_path, const char *filename);
	void load_local_score();
	void save_local_score();

	int add_local_score(const char *name, f32 time);

	void draw_highscore_board(f32 x, f32 y, const char *title, int num, struct score_t *score);
	
public:
	ControlHighscore();
	
	int update(WPADData *wiimote_data, int state);
	void draw(int state);
	void text(int state);
	
	void just_solved();
};

#endif
